<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* Name:  Auth Library
*
* Author: William Bermudo
*
*/

class Auth
{
	protected $messages;

	protected $errors = array();
	
	public function __construct()
	{
		$this->ci =& get_instance();
		$this->ci->load->model('users/users_m', 'users');
		$this->ci->lang->load('users/user');
	}
	
	public function login($identity, $password)
	{
		if ($this->ci->users->login($identity, $password))
		{
			return TRUE;
		}

		return FALSE;
	}
	
	public function is_logged_in()
	{
		if ($this->ci->session->userdata('logged_in'))
		{
			return TRUE;
		}
		
		return FALSE;
	}
	
	public function logout()
	{
		$this->ci->session->sess_destroy();
	}
	
	//public function set_message($message)
	//{
	//	$this->messages[] = $message;
	//
	//	return $message;
	//}
	//
	//public function messages()
	//{
	//	$_output = '';
	//	foreach ($this->messages as $message)
	//	{
	//		$_output .= $this->message_start_delimiter . $this->ci->lang->line($message) . $this->message_end_delimiter;
	//	}
	//
	//	return $_output;
	//}
	//
	//public function set_error($error)
	//{
	//	$this->errors[] = $error;
	//
	//	return $error;
	//}
	//
	//public function errors()
	//{
	//	$_output = '';
	//	foreach ($this->errors as $error)
	//	{
	//		$_output .= $this->error_start_delimiter . $this->ci->lang->line($error) . $this->error_end_delimiter;
	//	}
	//
	//	return $_output;
	//}
	
}